From 1d0ec27ff1c0e584f9014549accb5c508a7ce2cf Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 28 Jan 2009 17:40:01 +0000 Subject: [PATCH] x86: Pickle domain in page_info into 32 bits. Signed-off-by: Keir Fraser --- xen/arch/ia64/xen/domain.c | 10 ++++++++++ xen/arch/x86/domain.c | 19 +++++++++++++++++++ xen/common/domain.c | 10 ---------- xen/include/asm-x86/mm.h | 9 ++++++--- xen/include/xen/domain.h | 4 ++++ 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/xen/arch/ia64/xen/domain.c b/xen/arch/ia64/xen/domain.c index 52312fc969..b22304a1bb 100644 --- a/xen/arch/ia64/xen/domain.c +++ b/xen/arch/ia64/xen/domain.c @@ -405,6 +405,16 @@ void relinquish_vcpu_resources(struct vcpu *v) kill_timer(&v->arch.hlt_timer); } +struct domain *alloc_domain_struct(void) +{ + return xmalloc(struct domain); +} + +void free_domain_struct(struct domain *d) +{ + xfree(d); +} + struct vcpu *alloc_vcpu_struct(void) { struct page_info *page; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 1ee5482b96..e6fc0454b2 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -162,6 +162,25 @@ void dump_pageframe_info(struct domain *d) } } +struct domain *alloc_domain_struct(void) +{ + struct domain *d; + /* + * We pack the MFN of the domain structure into a 32-bit field within + * the page_info structure. Hence the MEMF_bits() restriction. + */ + d = alloc_xenheap_pages( + get_order_from_bytes(sizeof(*d)), MEMF_bits(32 + PAGE_SHIFT)); + if ( d != NULL ) + memset(d, 0, sizeof(*d)); + return d; +} + +void free_domain_struct(struct domain *d) +{ + free_xenheap_pages(d, get_order_from_bytes(sizeof(*d))); +} + struct vcpu *alloc_vcpu_struct(void) { struct vcpu *v; diff --git a/xen/common/domain.c b/xen/common/domain.c index ab807bfbf8..5a5888e46a 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -102,16 +102,6 @@ int current_domain_id(void) return current->domain->domain_id; } -static struct domain *alloc_domain_struct(void) -{ - return xmalloc(struct domain); -} - -static void free_domain_struct(struct domain *d) -{ - xfree(d); -} - static void __domain_finalise_shutdown(struct domain *d) { struct vcpu *v; diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 8c6fd64cca..7fa0bf9839 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -31,7 +31,7 @@ struct page_info /* Page is in use: ((count_info & PGC_count_mask) != 0). */ struct { /* Owner of this page (NULL if page is anonymous). */ - unsigned long _domain; /* pickled format */ + u32 _domain; /* pickled format */ /* Type reference count and various PGT_xxx flags and fields. */ unsigned long type_info; } inuse; @@ -173,8 +173,11 @@ struct page_info /* OOS fixup entries */ #define SHADOW_OOS_FIXUPS 2 -#define page_get_owner(_p) ((struct domain *)(_p)->u.inuse._domain) -#define page_set_owner(_p,_d) ((_p)->u.inuse._domain = (unsigned long)(_d)) +#define page_get_owner(_p) \ + ((struct domain *)((_p)->u.inuse._domain ? \ + mfn_to_virt((_p)->u.inuse._domain) : NULL)) +#define page_set_owner(_p,_d) \ + ((_p)->u.inuse._domain = (_d) ? virt_to_mfn(_d) : 0) #define maddr_get_owner(ma) (page_get_owner(maddr_to_page((ma)))) #define vaddr_get_owner(va) (page_get_owner(virt_to_page((va)))) diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index cf82d07ea0..65df554421 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -23,6 +23,10 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info); * Arch-specifics. */ +/* Allocate/free a domain structure. */ +struct domain *alloc_domain_struct(void); +void free_domain_struct(struct domain *d); + /* Allocate/free a VCPU structure. */ struct vcpu *alloc_vcpu_struct(void); void free_vcpu_struct(struct vcpu *v); -- 2.30.2